import time

import threading

request_record = {}

mutex_request_limit = threading.RLock()


def allow_request(host: str, path: str, millisecond: int):

    key = host + ":" + path

    cur_time_stamp = int(round(time.time() * 1000))

    with mutex_request_limit:
        if key in request_record:
            if cur_time_stamp - request_record[key] < millisecond:
                return False

        request_record[key] = cur_time_stamp

        return True
